package com.dongdongshop.domain;


import em.ResuleEnum;

public class AjaxResult<T> {
    private Integer code;
    private String message;
    private T data;
    private T rows;

    public static AjaxResult ok(){
        AjaxResult a = new AjaxResult();
        a.setCode(ResuleConstant.SUCCESS_CODE);
        a.setMessage(ResuleConstant.SUCCESS_MESSAGE);
        return a;
    }
    public static AjaxResult no(){
        AjaxResult a = new AjaxResult();
        a.setCode(ResuleConstant.ERROR_CODE);
        a.setMessage(ResuleConstant.ERROR_MESSAGE);
        return a;
    }

    public static AjaxResult response(){
        AjaxResult a = new AjaxResult();
        a.setCode(ResuleConstant.UNKNOWNACCOUNT_CODE);
        a.setMessage(ResuleConstant.UNKNOWNACCOUNT_MESSAGE);
        return a;
    }
    public static AjaxResult password(){
        AjaxResult a = new AjaxResult();
        a.setCode(ResuleConstant.INCORRECT_CODE);
        a.setMessage(ResuleConstant.INCORRECT_MESSAGE);
        return a;
    }
    public static AjaxResult yanzhengmano(){
        AjaxResult a = new AjaxResult();
        a.setCode(ResuleConstant.YANZHENGMANO_CODE);
        a.setMessage(ResuleConstant.YANZHENGMANO_MESSAGE);
        return a;
    }

    public static AjaxResult yanzhengmayes(){
        AjaxResult a = new AjaxResult();
        a.setCode(ResuleConstant.YANZHENGMAYES_CODE);
        a.setMessage(ResuleConstant.YANZHENGMAYES_MESSAGE);
        return a;
    }
    public static AjaxResult R (ResuleEnum resuleEnum){
        AjaxResult a = new AjaxResult();
        a.setCode(resuleEnum.getIndex());
        a.setMessage(resuleEnum.getName());
        return a;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public AjaxResult setData(T data) {
        this.data = data;
        return this;
    }

    public T getRows() {
        return rows;
    }

    public AjaxResult setRows(T rows) {
        this.rows = rows;
        return this;
    }
}
